package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.UserDAO;
import dao.UserDaoJdbcImpl;
import dao.UserInfoDAO;
import dao.UserInfoDaoJdbcImpl;

/**
 * Servlet implementation class UserDelServlet
 */
@WebServlet("/UserDelServlet")
public class UserDelServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UserDelServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String[] str=request.getParameterValues("username[]");
		UserDAO user = new UserDaoJdbcImpl();
		UserInfoDAO uInfo = new UserInfoDaoJdbcImpl();
		
		for(int i=0 ; i < str.length ; i++) {
			System.out.println(str[i]);
			uInfo.deleteUserInfo(str[i]);
			user.deleteUser(str[i]);
		}
//		Enumeration<String> pNames=request.getParameterNames();
//		while(pNames.hasMoreElements()){
//		    String name=(String)pNames.nextElement();
//		    String value=request.getParameter(name);
//		    System.out.print(name );
//		    System.out.print("1");
//		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
